//
//  BFShSettingHomeViewController.m
//  BeautyFood
//
//  Created by apple on 2020/5/2.
//  Copyright © 2020 stoneobs. All rights reserved.
//

#import "THAccountMangerViewController.h"
#import "THChangedPwdViewController.h"
@interface THAccountMangerViewController ()
@property(nonatomic, strong) NSMutableArray<NSArray*>                     *dataSouce;/**<  */
@end

@implementation THAccountMangerViewController

#pragma mark --vc生命周期
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"账号管理";
    [self config_dataSouce];
    // Do any additional setup after loading the view.
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated{
    [super viewDidDisappear:animated];
}
- (void)config_dataSouce{
    self.dataSouce = NSMutableArray.new;

    THUserModel * user = STTools_UserManger.defult.stoneobs_fun_get_loginedUser;
    ({
       NSArray * array = @[
           [[STTools_TableEasyModel alloc] initWithTextString:@"手机号" detailString:user.phone],
           [[STTools_TableEasyModel alloc] initWithTextString:@"修改密码" detailString:@""],
           [[STTools_TableEasyModel alloc] initWithTextString:@"微信" detailString:user.third.app_name.length?user.third.app_name:@"未绑定"],
       ];
        [self.dataSouce addObject:array];
    });
    
    [self.tableView reloadData];
}

#pragma --mark UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return self.dataSouce.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.dataSouce[section].count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 50;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    return 0.01;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return nil;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 20;
}
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString * reuseIdentifier =  @"cell";
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuseIdentifier];
        
    }
    STTools_TableEasyModel * model = self.dataSouce[indexPath.section][indexPath.row];
    [cell setSt_tableEasyModel:model];
    if (indexPath.row == 0) {
        cell.accessoryType = UITableViewCellAccessoryNone;
    }else{
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    
    return cell;
}
#pragma --mark UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    STTools_TableEasyModel * model = self.dataSouce[indexPath.section][indexPath.row];
    if ([model.textString isEqualToString:@"修改密码"]) {
        [self pushViewController:THChangedPwdViewController.new animated:1];
    }
    if ([model.textString isEqualToString:@"微信"]) {

    }

    
    [self.tableView deselectRowAtIndexPath:indexPath animated:NO];
}

@end
